
<?php
session_start();

include("connect.php");
if(isset($_GET['action'])){//判断页面动作
     if($_GET['action']=="logout"){
		 $backurl=$_GET['backurl'];
		 session_destroy();
		  echo "<script language='javascript' type='text/javascript'>";//跳转回进入的页面
          print("window.location.href='$backurl'");
          echo "</script>";
		 
		 }
}
     else{
		 $username=$_POST['username'];
         $password=$_POST['password'];
         $backurl=$_POST['backurl'];
		 $userResult=mysql_fetch_array(mysql_query("select * from user where username='$username' and         password='$password'"));
         if($userResult['username']!=null){
	         $_SESSION['username']=$userResult['username'];
	         $_SESSION['loged']=true;
             //print($_SESSION['loged']);
              echo "<script language='javascript' type='text/javascript'>";//跳转回进入的页面
              print("window.location.href='$backurl'");
             echo "</script>";
            // print("<a href='http://dmc3guide.sinaapp.com?id='>ddd</a>'");
             //print("ddd");
              
             // print($userResult['username']);

	         }
        else{
          	 print($username);
	         print("wrong");
	         }
		}
	
	



?>
